package org.smarthings.things.management.rest;

import java.util.Map;

import javax.ws.rs.DELETE;
import javax.ws.rs.GET;
import javax.ws.rs.POST;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
import javax.ws.rs.QueryParam;
import javax.ws.rs.WebApplicationException;
import javax.ws.rs.core.Response;

import org.smarthings.things.commons.rest.VersionResource;
import org.smarthings.things.management.rest.resources.ThingCollectionResource;
import org.smarthings.things.management.rest.resources.ThingRegistrationResource;
import org.smarthings.things.management.rest.resources.ThingResource;
import org.smarthings.things.management.rest.resources.actions.ThingActionCollectionResource;
import org.smarthings.things.management.rest.resources.actions.ThingActionExecutionResource;
import org.smarthings.things.management.rest.resources.actions.ThingActionResource;
import org.smarthings.things.management.rest.resources.properties.ThingPropertyCollectionResource;
import org.smarthings.things.management.rest.resources.properties.ThingPropertyResource;

@Path("things")
public interface RemoteThingsRegistrationsManagement {

	@GET
	@Path("version")
	VersionResource getVersion() throws WebApplicationException;

	@POST
	@Path("registrations")
	Response registerThing(ThingRegistrationResource registration) throws WebApplicationException;

	@DELETE
	@Path("registrations/{thingUUID}")
	Response unregisterThing(@PathParam("thingUUID") String thingUUID)
			throws WebApplicationException;

	@GET
	ThingCollectionResource getThings(@QueryParam("filter") String filter)
			throws WebApplicationException;

	@GET
	@Path("{thingUUID}")
	ThingResource getThing(@PathParam("thingUUID") String thingUUID) throws WebApplicationException;

	@GET
	@Path("{thingUUID}/state")
	int getThingStateSimple(@PathParam("thingUUID") String thingUUID)
			throws WebApplicationException;

	@POST
	@Path("{thingUUID}/state")
	int updateThingSateSimple(@PathParam("thingUUID") String thingUUID, int state)
			throws WebApplicationException;

	@GET
	@Path("{thingUUID}/properties")
	ThingPropertyCollectionResource getThingProperties(@PathParam("thingUUID") String thingUUID)
			throws WebApplicationException;

	@GET
	@Path("{thingUUID}/properties/{propertyUUID}")
	ThingPropertyResource getThingProperty(@PathParam("thingUUID") String thingUUID,
			@PathParam("propertyUUID") String propertyUUID) throws WebApplicationException;

	@GET
	@Path("{thingUUID}/properties/{propertyUUID}/value")
	String getThingPropertySimple(@PathParam("thingUUID") String thingUUID,
			@PathParam("propertyUUID") String propertyUUID) throws WebApplicationException;

	@POST
	@Path("{thingUUID}/properties/{propertyUUID}")
	ThingPropertyResource updateThingProperty(@PathParam("thingUUID") String thingUUID,
			@PathParam("propertyUUID") String propertyUUID, ThingPropertyResource updated)
			throws WebApplicationException;

	@POST
	@Path("{thingUUID}/properties/{propertyUUID}/value")
	String updateThingPropertySimple(@PathParam("thingUUID") String thingUUID,
			@PathParam("propertyUUID") String propertyUUID, String updated)
			throws WebApplicationException;

	@GET
	@Path("{thingUUID}/actions")
	ThingActionCollectionResource getThingActions(@PathParam("thingUUID") String thingUUID)
			throws WebApplicationException;

	@GET
	@Path("{thingUUID}/actions/{actionUUID}")
	ThingActionResource getThingAction(@PathParam("thingUUID") String thingUUID,
			@PathParam("actionUUID") String actionUUID) throws WebApplicationException;

	@POST
	@Path("{thingUUID}/actions/executions/{actionUUID}")
	Response executeThingAction(@PathParam("thingUUID") String thingUUID,
			@PathParam("actionUUID") String actionUUID, ThingActionExecutionResource arguments)
			throws WebApplicationException;

	@POST
	@Path("{thingUUID}/actions/executions/{actionUUID}/arguments")
	Response executeThingActionSimple(@PathParam("thingUUID") String thingUUID,
			@PathParam("actionUUID") String actionUUID, Map<String, String> arguments)
			throws WebApplicationException;

	@GET
	@Path("{thingUUID}/actions/executions/{actionUUID}/arguments")
	Map<String, String> getLastThingActionExecutionSimple(@PathParam("thingUUID") String thingUUID,
			@PathParam("actionUUID") String actionUUID) throws WebApplicationException;

}
